import { modules } from './modules';
//① 匹配到了所有mutations
type GetMutation<Module> = Module extends { mutations: infer M } ? M : unknown;
//② 取都我的mutations里的key mutations[key]
type GetMutations<Modules> = {
  [K in keyof Modules]: GetMutation<Modules[K]>;
};
type ModuleMuations = GetMutations<typeof modules>;

//获取全部Getter
type GetGetter<Module> = Module extends { getters: infer G } ? G : unknown;
type GetGetters<Modules> = {
  [K in keyof Modules]: GetGetter<Modules[K]>;
};
type ModuleGetters = GetGetters<typeof modules>;

//拼最后的刚需
type AddPrefix<Profix,Keys> = `${Profix&string}/${Keys & string}`;

type GetSpilceKey<Module,Key> = AddPrefix<Key,keyof Module> 

// {
//   "user/isLogin":()=>{}
// }
type GetSpilceKeys<Modules> = {
  [K in keyof Modules]:GetSpilceKey<Modules[K],K>
}[keyof Modules]
// type xx = GetSpilceKeys<ModuleGetters>
type GetFunc<T,A,B> = T[A & keyof T][B &  keyof T[A & keyof T]];
type GetSpilceObj<T> = {
[K  in GetSpilceKeys<T>]:K extends  `${infer A}/${infer B}` ?GetFunc<T,A,B>:unknown;
}
type Getters = GetSpilceObj<ModuleGetters>;
